<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta
    name="viewport"
    content="width=device-width, initial-scale=1.0"
  >
  <title>Document</title>
</head>

<body>
  <html>

  </html>
  <script>
    window.onload = function () {
      var inputElement = document.createElement('textarea');
      inputElement.id = "scanned-input";
      document.body.appendChild(inputElement);
      inputElement.focus()

      inputElement.addEventListener('input', function (e) {
        var scannedData = e.target.value;
        if (scannedData.endsWith('\n')) {
          console.log('发请求', scannedData);
          e.target.value = '';
        }
      });
    };
  </script>
</body>

</html>